package com.geor.gcv.core.process;

import org.opencv.core.Mat;
import org.opencv.imgproc.Imgproc;

/**
 * 灰度处理
 * 
 * @author geor.lusongnan
 *
 */
public class GrayProcess extends Process {
	Process chain;
	Mat img;

	public GrayProcess(Process chain) {
		this.chain = chain;
	}

	public GrayProcess(Mat img) {
		this.img = img;
	}

	@Override
	public Mat process() {
		if (img == null && chain != null) {
			img = chain.process();
		}
		Mat result = new Mat();
		Imgproc.cvtColor(img, result, Imgproc.COLOR_RGB2GRAY);
		return result;
	}

	@Override
	public String getProcessName() {
		return chain.getProcessName() + "-->灰度处理";
	}

}
